import Vue from "vue";
import Vuex from "vuex";
import axios from "axios"

Vue.use(Vuex);

const state = {
	// 用户昵称
	nickName: "",
	// 用户性别
	sex: "",
	// 用户电话
	tel: "",
	// 用户生日
	date: "",
	// 点餐菜品详情列表
	menuList: [],
}

const getters = {};

const actions = {
	async getMenuList({commit}) {
		await uni.request({
			method: "GET"                                                                                                                                                                                                                                                                                                                                                                                                                                                         ,
			url: "https://majesty2.xyz/api/v1/data/get/app-detail-menu-list"
		}).then(res => {
			console.log(res,"res");
			commit('SetMenuList', res[1].data.data.menuList)
		})
	}
};

const mutations = {
	setNickName(state, data) {
		state.nickName = data;
	},
	setSex(state, data) {
		state.sex = data;
	},
	setTel(state, data) {
		state.tel = data;
	},
	setDate(state, data) {
		state.date = data;
	},
	SetMenuList(state, data) {
		state.menuList = data
	},
};

export default new Vuex.Store({
	state,
	getters,
	actions,
	mutations,
})